apiVersion: v1
kind: BuildConfig
metadata:
  name: "transtats-build"
  labels:
    environment: "transtats"
spec:
  runPolicy: Serial
  source:
    dockerfile: |-
      FROM registry.fedoraproject.org/fedora:34
      USER root
      RUN useradd -ms /bin/bash tsuser
      RUN dnf -y update && \
          dnf -y install git make cpio koji file patch intltool libtool gtk3-devel npm supervisor redis libxcrypt-compat python3-pip && \
          dnf clean all
      RUN mkdir /workspace
      ENV PYTHONUNBUFFERED 1
      WORKDIR /workspace
      RUN git clone -b main https://github.com/transtats/transtats.git .
      RUN pip3 install -r /workspace/requirements/base.txt
      RUN cp deploy/docker-compose/transtats/launch.sh /usr/bin/transtats.sh
      RUN cp deploy/docker-compose/transtats/wait-for-it.sh /usr/bin/wait-for-it.sh
      RUN cp deploy/docker/conf/supervisord.conf /etc/supervisord.conf
      RUN cp deploy/docker/conf/redis.ini /etc/supervisord.d/
      RUN cp deploy/docker/conf/transtats_celery.ini /etc/supervisord.d/
      RUN cp deploy/docker/conf/transtats_celerybeat.ini /etc/supervisord.d/
      RUN mkdir staticfiles false run transtats/logs/celery
      RUN touch /workspace/transtats/logs/celery/redis.log
      RUN touch /workspace/transtats/logs/celery/redis_err.log
      RUN touch /workspace/transtats/logs/celery/transtats_worker.log
      RUN touch /workspace/transtats/logs/celery/transtats_beat.log
      RUN chmod -R g+w transtats/logs transtats/node dashboard/sandbox staticfiles false run
      RUN chown -R tsuser /workspace
      EXPOSE 8080
      USER tsuser
      ENTRYPOINT ["/usr/bin/transtats.sh"]
    type: Dockerfile
  strategy:
    dockerStrategy:
      noCache: true
      env:
      - name: UPGRADE_PIP_TO_LATEST
        value: "true"
      - name: PIP_INDEX_URL
      - name: TS_AUTH_SYSTEM
        valueFrom:
          secretKeyRef:
            name: transtats-secret
            key: ts-auth-system
      - name: ADMIN_PASSWORD
        valueFrom:
          secretKeyRef:
            name: transtats-secret
            key: admin-password
      - name: OIDC_BASE_DOMAIN
        valueFrom:
          secretKeyRef:
            name: transtats-secret
            key: oidc_url
      - name: OIDC_RP_CLIENT_ID
        valueFrom:
          secretKeyRef:
            name: transtats-secret
            key: oidc-client-id
      - name: OIDC_RP_CLIENT_SECRET
        valueFrom:
          secretKeyRef:
            name: transtats-secret
            key: oidc-client-secret
      - name: DJANGO_SECRET_KEY
        valueFrom:
          secretKeyRef:
            name: transtats-secret
            key: django-secret-key
    type: Docker
  output:
    to:
      kind: ImageStreamTag
      name: transtats:latest
